import fetch from 'common/src/utils/fetch'
// let apiPrefix = '/dev/';
let apiPrefix = '/api/studentservice/';
/**
 *
 * @param {*} data 筛选条件
 */
export function getAbnormalTypeList (data = {}) {
    return fetch({
        url: apiPrefix + 'type/typeList',
        method: 'post',
        data
    });
}
// 根据异动大类获取该大类下的所有异动类型
export function getAbnormalTypeByClassCode (data = '') {
    return fetch({
        url: apiPrefix + 'type/typesByClassCode/' + data,
        method: 'get',
        headers: {
            'Content-Type': 'application/json'
        }
    });
}
// 判断异动类型代码是否存在
export function checkIsExistCode(data = {}) {
    return fetch({
        url: apiPrefix + 'type/checkIsExistCode',
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        data,
        showMask: false
    });
}
// 判断异动大类 + 异动类型是否存在
export function checkIsExistName(data = {}) {
    return fetch({
        url: apiPrefix + 'type/checkIsExistName',
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        data,
        showMask: false
    });
}
// 添加异动类型
export function addAbnormalType (data = {}) {

    return fetch({
        url: apiPrefix + 'type/addType',
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}
// 修改异动类型
export function updateAbnormalType (data = {}) {
    return fetch({
        url: apiPrefix + 'type/updateType',
        method: 'put',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}

// 根据id获取异动类型详情
export function getTypeDetailByTypeId(id = '') {
    return fetch({
        url: apiPrefix + 'type/typeDetailByTypeId/' + id,
        method: 'get',
        headers: {
            'Content-Type': 'application/json'
        }
    });
}
// 根据类型id获取异动原因列表
export function getReasonsByTypeId(id) {
    return fetch({
        url: apiPrefix + 'reason/allReasonsByTypeId/'+id,
        method: 'get',
        headers: {
            'Content-Type': 'application/json'
        }
    });
}
// 更新异动原因
export function updateReasons(data) {
    return fetch({
        url: apiPrefix + 'reason/updateReason',
        method: 'put',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}
// 获取异动字段权限列表
export function getFieldsAuthByTypeId(id) {
    return fetch({
        url: apiPrefix + 'fieldAuth/fieldAuthsByTypeId/'+id,
        method: 'get',
        headers: {
            'Content-Type': 'application/json'
        }
    });
}
// 更新异动权限
export function updateFieldAuths(data = []) {
    return fetch({
        url: apiPrefix + 'fieldAuth/updateFieldAuths',
        method: 'put',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}
// 获取所有学籍字段
 export function getAllStuDicts() {
    return fetch({
        url: apiPrefix + 'studentDic/findAllStuDicts',
        method: 'get',
        headers: {
            'Content-Type': 'application/json'
        }
    });
 }

// 获取所有学籍字段(new)
export function findStuDicts() {
    return fetch({
        url: apiPrefix + 'studentDic/findStuStatusDic',
        method: 'get',
        headers: {
            'Content-Type': 'application/json'
        }
    });
 }

 // 根据异动类型id过去该异动类型下的所有异动字段
 export function getFieldsByTypeId(id = '') {
    return fetch({
        url: apiPrefix + 'field/fieldsByCode/' + id,
        method: 'get',
        headers: {
            'Content-Type': 'application/json'
        }
    });
 }
// 更新异动字段
export function updateFields(data = []) {
    return fetch({
        url: apiPrefix + 'field/updateFields',
        method: 'put',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}
// 获取申请异动列表
export async function getApplyAbnormalList(data = {}){
    return fetch({
        url: '/api/studentservice/apply/applyList',
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}
// 修改异动类型
// 根据id查异动详情
export function getAbnormalDetailById(data = {}) {
    return fetch({
        url: '/api/studentservice/apply/applyDetail',
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}
// 获取异动原因列表
export function getAbnormalReasons(data = {}) {
    return fetch({
        url: '/api/studentservice/reason/reasonList',
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}
//申请异动
export function doApplyAbnormal(data = {}) {
    return fetch({
        url: '/api/studentservice/apply/addApply',
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    })
}
// 获取学生基本信息
export async function getStudentDetail(data = []) {
    return fetch({
        url: '/api/studentservice/studentInfo/findStuInfoListByUserIds',
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}

// 异动原因 （根据异动类型 查询异动原因）
export function getAbnormalReason(typeCode = '') {
    return fetch({
        url: `/api/studentservice/reason/reasonsByCode/${typeCode}`,
        method: 'get'
    });
 }
 /**
  * 查询异动日志列表
  * @param {*} data 查询条件
  */
export function abnormalLogsQuery(data={}) {
    return fetch({
        url: '/api/studentservice/apply/abnormalLogsQuery',
        method: 'post',
        data
    });
 }
 /**
  *     查询获取学生全部基本信息
  * @param {*} studentId
  */
 export function queryStudentInfoByStudentId(studentId = '') {
    return fetch({
        url: apiPrefix + 'apply/queryStudentInfoByStudentId?studentId=' + studentId,
        method: 'get'
    });
 }

 /**
  *     查询管理审核状态下拉框数组
  * @param {*} null 无参数
  */
 export function getAbnormalStatus() {
    return fetch({
        url: apiPrefix + 'apply/getAbnormalStatus',
        method: 'get'
    });
 }
 /**
  *
  * @param {*} workFlowNo 流程编号
  * 查询审批详细流程
  */
export function selectApproveHistory(workFlowNo) {
    return fetch({
        url: apiPrefix+'apply/selectApproveHistory?workFlowNo=' + workFlowNo,
        method: 'get'
    });
}

/**
 *
 * @param {*} data
 * 示例参数
 * {
    "abnormalStartTime": 1574092800000,
    "abnormalEndTime": 1574179200000,
    "studentId": "1956102",
    "id": 873
  }
 * 更新异动开始/结束时间
 */
export function updateAbnormalTime(data={}) {
    return fetch({
        url: apiPrefix+'/apply/updateAbnormalTime',
        method: 'post',
        data
    });
}

export function approveSave(data={}) {
    return fetch({
        url: apiPrefix+'/apply/approveSave',
        method: 'post',
        data
    });
}

export function deleteAbnormalType(data={}) {
    return fetch({
        url: apiPrefix +'type/deleteAbnormalType',
        method: 'post',
        data
    });
}
